import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import request from './api/request.js'
import { aes_encrypt, aes_decrypt } from '@/api/aes_endecrypt.js';
Vue.prototype.aes_encrypt = aes_encrypt;
Vue.prototype.aes_decrypt = aes_decrypt;

// import globalPul from './api/globalPul.js'
import {
	parseTime
} from './api/api.js'

Vue.config.productionTip = false

Vue.prototype.$get = request.get;
Vue.prototype.$post = request.post;
Vue.prototype.$postJson = request.postJson;
Vue.prototype.$utils = request;

import uView from '@/uni_modules/uview-ui'
Vue.use(uView)





App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()

Vue.prototype.strIsEmpty = function(str) {
	if (str) {
		if (str == 'null' || str == 'undefined' || str == null || str == "" || str == undefined) {
			return true
		}
		return false
	}
	return true

}

Vue.prototype.parseTime = parseTime


Vue.prototype.formatDate2 = function(time, cFormat) {
	if (!time) {
		return '-'
	}
	var date = new Date(time);
	const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
	const formatObj = {
		y: date.getFullYear(),
		m: date.getMonth() + 1,
		d: date.getDate(),
		h: date.getHours(),
		i: date.getMinutes(),
		s: date.getSeconds(),
		a: date.getDay()
	}
	const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
		let value = formatObj[key]
		// Note: getDay() returns 0 on Sunday
		if (key === 'a') {
			return ['日', '一', '二', '三', '四', '五', '六'][value]
		}
		if (result.length > 0 && value < 10) {
			value = '0' + value
		}
		return value || 0
	})
	return time_str
}



// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif